IF OBJECT_ID('ssf.job_generate_jobstep_run_id') IS NOT NULL
	DROP FUNCTION ssf.job_generate_jobstep_run_id
GO

CREATE FUNCTION ssf.job_generate_jobstep_run_id (
	@job_name NVARCHAR(128)
	, @jobstep_id INT
	, @jobstep_start_datetime DATETIME
	, @parent_job_name NVARCHAR(128)
	, @parent_job_start_datetime DATETIME
)
RETURNS XML
AS
BEGIN
	RETURN (
		SELECT @job_name AS job_name
			, @jobstep_id AS jobstep_id
			, @jobstep_start_datetime AS jobstep_start_datetime
			, @parent_job_name AS parent_job_name
			, @parent_job_start_datetime AS parent_job_start_datetime
			, @@SPID AS jobstep_spid
		FOR XML RAW('jobstep_run_id')
	)
END
GO
